package com.jeecg.p3.system.advisor.service;

import com.jeecg.p3.system.advisor.dao.StuAdvGroupDao;
import com.jeecg.p3.system.advisor.entity.StuAdvGroup;
import com.jeecg.p3.system.entity.JwSystemRole;
import org.jeecgframework.p3.core.utils.common.PageList;
import org.jeecgframework.p3.core.utils.common.PageQuery;
import org.jeecgframework.p3.core.utils.common.PageQueryWrapper;
import org.jeecgframework.p3.core.utils.common.Pagenation;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * TODO
 * Created on 2020-08-28$ 21:30$
 *
 * @author 张晓$
 * @version V1.0
 */
@Service("stuAdvGroupService")
public class StuAdvGroupService {
    @Resource
    private StuAdvGroupDao advGroupDao;

    /**
     * 分页查询根据传参
     * @param pageQuery
     * @return
     */
    public PageList<StuAdvGroup> queryPageList(PageQuery<StuAdvGroup> pageQuery) {
        PageList<StuAdvGroup> result = new PageList<StuAdvGroup>();
        Integer itemCount = advGroupDao.count(pageQuery);
        PageQueryWrapper<StuAdvGroup> wrapper = new PageQueryWrapper<StuAdvGroup>(pageQuery.getPageNo(), pageQuery.getPageSize(),itemCount, pageQuery.getQuery());
        List<StuAdvGroup> list = advGroupDao.queryPageList(wrapper);
        Pagenation pagenation = new Pagenation(pageQuery.getPageNo(), itemCount, pageQuery.getPageSize());
        result.setPagenation(pagenation);
        result.setValues(list);
        return result;
    }

    /**
     * 新增群组信息
     * @param stuAdvGroup
     */
    public void doAdd(StuAdvGroup stuAdvGroup) {
        advGroupDao.insert(stuAdvGroup);
    }

    /**
     * 编辑群组信息
     * @param stuAdvGroup
     */
    public void doEdit(StuAdvGroup stuAdvGroup) {
        advGroupDao.update(stuAdvGroup);
    }

    /**
     * 根据id查询分组信息
     * @param id
     * @return
     */
    public StuAdvGroup findById(Long id) {
        return advGroupDao.get(id);
    }

    /**
     * 逻辑删除分组信息，状态置为0
     * @param stuAdvGroup
     */
    public void doDelete(StuAdvGroup stuAdvGroup) {
        stuAdvGroup.setStatus("0");
        advGroupDao.update(stuAdvGroup);
    }

    /**
     * 查询分组列表
     * @param stuAdvGroup
     * @return
     */
    public List<StuAdvGroup> findList(StuAdvGroup stuAdvGroup) {
        return advGroupDao.findList(stuAdvGroup);
    }
}
